var express = require('express');
var router = express.Router();
// 七牛云模块
const qiniu = require('qiniu')
const { Ak, Sk } = require('../config/index')

router.get('/uploadToken', (req, res) => {
  // 构建鉴权对象
  const mac = new qiniu.auth.digest.Mac(Ak, Sk);
  const options = {
    scope: 'water-q',
  };
  const putPolicy = new qiniu.rs.PutPolicy(options);
  const uploadToken = putPolicy.uploadToken(mac);
  res.json({
    code: 200,
    data: uploadToken,
    msg: "success"
  })
})

module.exports = router